﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace MESMian.Migrations
{
    /// <inheritdoc />
    public partial class updateAllmapping1 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "DeviceCategories",
                columns: table => new
                {
                    DeviceCategoryId = table.Column<int>(type: "int", nullable: false, comment: "设备类型主键，自动编号")
                        .Annotation("SqlServer:Identity", "1, 1"),
                    DeviceCategoryName = table.Column<string>(type: "varchar(30)", nullable: false, comment: "设备类型名称，不能重复"),
                    Status = table.Column<int>(type: "int", nullable: false, defaultValue: 0, comment: "数据状态（0正常，1删除），默认值0"),
                    CreateUserId = table.Column<int>(type: "int", nullable: false, comment: "创建人，外键（Users）"),
                    CreateTime = table.Column<DateTime>(type: "datetime", nullable: false, defaultValueSql: "GETDATE()", comment: "创建时间，默认值为当前时间"),
                    LastUpdateUserId = table.Column<int>(type: "int", nullable: true, comment: "最后一次修改人，外键（Users）"),
                    LastUpdateTime = table.Column<DateTime>(type: "datetime", nullable: true, comment: "最后一次修改时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_DeviceCategories", x => x.DeviceCategoryId);
                });

            migrationBuilder.CreateTable(
                name: "DeviceInspections",
                columns: table => new
                {
                    DeviceInspectionId = table.Column<int>(type: "int", nullable: false, comment: "设备巡检主键，自动编号")
                        .Annotation("SqlServer:Identity", "1, 1"),
                    DeviceId = table.Column<int>(type: "int", nullable: false, comment: "巡检设备，外键（Devices）"),
                    CurrentDeviceStatus = table.Column<int>(type: "int", nullable: false, defaultValue: 1, comment: "设备状态（1使用中，2维修中，3其他），默认值1"),
                    InspectorId = table.Column<int>(type: "int", nullable: false, comment: "巡检人员，外键（Users）"),
                    InspectionTime = table.Column<DateTime>(type: "datetime", nullable: false, comment: "巡检日期"),
                    Remark = table.Column<string>(type: "varchar(150)", nullable: true, comment: "备注"),
                    Status = table.Column<int>(type: "int", nullable: false, defaultValue: 0, comment: "数据状态（0正常，1删除），默认值0"),
                    CreateUserId = table.Column<int>(type: "int", nullable: false, comment: "创建人，外键（Users）"),
                    CreateTime = table.Column<DateTime>(type: "datetime", nullable: false, defaultValueSql: "GETDATE()", comment: "创建时间，默认值为当前时间"),
                    LastUpdateUserId = table.Column<int>(type: "int", nullable: true, comment: "最后一次修改人，外键（Users）"),
                    LastUpdateTime = table.Column<DateTime>(type: "datetime", nullable: true, comment: "最后一次修改时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_DeviceInspections", x => x.DeviceInspectionId);
                });

            migrationBuilder.CreateTable(
                name: "DeviceMaintenances",
                columns: table => new
                {
                    DeviceMaintenanceId = table.Column<int>(type: "int", nullable: false, comment: "设备维修主键，自动编号")
                        .Annotation("SqlServer:Identity", "1, 1"),
                    DeviceId = table.Column<int>(type: "int", nullable: false, comment: "维修设备，外键（Devices）"),
                    MaintainerId = table.Column<int>(type: "int", nullable: false, comment: "维修人员，外键（Users）"),
                    MaintenanceTime = table.Column<DateTime>(type: "datetime", nullable: false, comment: "维修日期（填写日期）"),
                    Remark = table.Column<string>(type: "varchar(150)", nullable: true, comment: "报修简述"),
                    Status = table.Column<int>(type: "int", nullable: false, defaultValue: 0, comment: "数据状态（0正常，1删除），默认值0"),
                    CreateUserId = table.Column<int>(type: "int", nullable: false, comment: "创建人，外键（Users）"),
                    CreateTime = table.Column<DateTime>(type: "datetime", nullable: false, defaultValueSql: "GETDATE()", comment: "创建时间，默认值为当前时间"),
                    LastUpdateUserId = table.Column<int>(type: "int", nullable: true, comment: "最后一次修改人，外键（Users）"),
                    LastUpdateTime = table.Column<DateTime>(type: "datetime", nullable: true, comment: "最后一次修改时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_DeviceMaintenances", x => x.DeviceMaintenanceId);
                });

            migrationBuilder.CreateTable(
                name: "Devices",
                columns: table => new
                {
                    DeviceId = table.Column<int>(type: "int", nullable: false, comment: "设备主键，自动编号")
                        .Annotation("SqlServer:Identity", "1, 1"),
                    DeviceCode = table.Column<string>(type: "varchar(20)", nullable: false, comment: "设备编码，不能重复"),
                    DeviceName = table.Column<string>(type: "varchar(30)", nullable: false, comment: "设备名称，不能重复"),
                    DeviceCategoryId = table.Column<int>(type: "int", nullable: false, comment: "设备类型，外键（DeviceCategories）"),
                    DeviceSpecId = table.Column<int>(type: "int", nullable: false, comment: "设备规格，外键（DeviceSpecs）"),
                    DeviceUnitId = table.Column<int>(type: "int", nullable: false, comment: "单位，外键（Units）"),
                    DeviceStatus = table.Column<int>(type: "int", nullable: false, defaultValue: 0, comment: "设备状态（0在库中，1使用中，2维修中，3其他），默认值0"),
                    RegisterId = table.Column<int>(type: "int", nullable: false, comment: "登录人，外键（Users）"),
                    RegisterTime = table.Column<DateTime>(type: "datetime", nullable: false, comment: "登录日期"),
                    Remark = table.Column<string>(type: "varchar(150)", nullable: true, comment: "备注"),
                    Status = table.Column<int>(type: "int", nullable: false, defaultValue: 0, comment: "数据状态（0正常，1删除），默认值0"),
                    CreateUserId = table.Column<int>(type: "int", nullable: false, comment: "创建人，外键（Users）"),
                    CreateTime = table.Column<DateTime>(type: "datetime", nullable: false, defaultValueSql: "GETDATE()", comment: "创建时间，默认值为当前时间"),
                    LastUpdateUserId = table.Column<int>(type: "int", nullable: true, comment: "最后一次修改人，外键（Users）"),
                    LastUpdateTime = table.Column<DateTime>(type: "datetime", nullable: true, comment: "最后一次修改时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Devices", x => x.DeviceId);
                });

            migrationBuilder.CreateTable(
                name: "DeviceSpecs",
                columns: table => new
                {
                    DeviceSpecId = table.Column<int>(type: "int", nullable: false, comment: "设备规格主键，自动编号")
                        .Annotation("SqlServer:Identity", "1, 1"),
                    DeviceSpecName = table.Column<string>(type: "varchar(30)", nullable: false, comment: "设备规格名称，不能重复"),
                    Status = table.Column<int>(type: "int", nullable: false, defaultValue: 0, comment: "数据状态（0正常，1删除），默认值0"),
                    CreateUserId = table.Column<int>(type: "int", nullable: false, comment: "创建人，外键（Users）"),
                    CreateTime = table.Column<DateTime>(type: "datetime", nullable: false, defaultValueSql: "GETDATE()", comment: "创建时间，默认值为当前时间"),
                    LastUpdateUserId = table.Column<int>(type: "int", nullable: true, comment: "最后一次修改人，外键（Users）"),
                    LastUpdateTime = table.Column<DateTime>(type: "datetime", nullable: true, comment: "最后一次修改时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_DeviceSpecs", x => x.DeviceSpecId);
                });

            migrationBuilder.CreateTable(
                name: "MaterialReceiveDetails",
                columns: table => new
                {
                    MaterialReceiveDetailId = table.Column<int>(type: "int", nullable: false, comment: "产品生产领料明细主键，自动编号")
                        .Annotation("SqlServer:Identity", "1, 1"),
                    MaterialReceiveId = table.Column<int>(type: "int", nullable: false, comment: "产品生产领料主键，外键（MaterialReceives）"),
                    ProductionPlanDetailId = table.Column<int>(type: "int", nullable: false, comment: "生产计划明细主键，外键（ProductionPlanDetails）"),
                    StoreId = table.Column<int>(type: "int", nullable: false, comment: "领料仓库，外键（Stores）"),
                    ReceiveCount = table.Column<int>(type: "int", nullable: false, comment: "预计需要物料的数量"),
                    Status = table.Column<int>(type: "int", nullable: false, defaultValue: 0, comment: "数据状态（0正常，1删除），默认值0"),
                    CreateUserId = table.Column<int>(type: "int", nullable: false, comment: "创建人，外键（Users）"),
                    CreateTime = table.Column<DateTime>(type: "datetime", nullable: false, defaultValueSql: "GETDATE()", comment: "创建时间，默认值为当前时间"),
                    LastUpdateUserId = table.Column<int>(type: "int", nullable: true, comment: "最后一次修改人，外键（Users）"),
                    LastUpdateTime = table.Column<DateTime>(type: "datetime", nullable: true, comment: "最后一次修改时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MaterialReceiveDetails", x => x.MaterialReceiveDetailId);
                });

            migrationBuilder.CreateTable(
                name: "MaterialReceives",
                columns: table => new
                {
                    MaterialReceiveId = table.Column<int>(type: "int", nullable: false, comment: "产品生产领料主键，自动编号")
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ProductionPlanId = table.Column<string>(type: "varchar(20)", nullable: false, comment: "生产计划，外键（ProductionPlans）"),
                    ReceiveId = table.Column<int>(type: "int", nullable: false, comment: "领料人，外键（Users）"),
                    ReceiveDate = table.Column<DateTime>(type: "datetime", nullable: false, comment: "领料日期"),
                    Status = table.Column<int>(type: "int", nullable: false, defaultValue: 0, comment: "数据状态（0正常，1删除），默认值0"),
                    CreateUserId = table.Column<int>(type: "int", nullable: false, comment: "创建人，外键（Users）"),
                    CreateTime = table.Column<DateTime>(type: "datetime", nullable: false, defaultValueSql: "GETDATE()", comment: "创建时间，默认值为当前时间"),
                    LastUpdateUserId = table.Column<int>(type: "int", nullable: true, comment: "最后一次修改人，外键（Users）"),
                    LastUpdateTime = table.Column<DateTime>(type: "datetime", nullable: true, comment: "最后一次修改时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MaterialReceives", x => x.MaterialReceiveId);
                });

            migrationBuilder.CreateTable(
                name: "ProductionLineCategories",
                columns: table => new
                {
                    ProductionLineCategoryId = table.Column<int>(type: "int", nullable: false, comment: "产线类型主键，自动编号")
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ProductionLineCategoryName = table.Column<string>(type: "varchar(30)", nullable: false, comment: "产线类型名称，不能重复"),
                    Status = table.Column<int>(type: "int", nullable: false, defaultValue: 0, comment: "数据状态（0正常，1删除），默认值0"),
                    CreateUserId = table.Column<int>(type: "int", nullable: false, comment: "创建人，外键（Users）"),
                    CreateTime = table.Column<DateTime>(type: "datetime", nullable: false, defaultValueSql: "GETDATE()", comment: "创建时间，默认值为当前时间"),
                    LastUpdateUserId = table.Column<int>(type: "int", nullable: true, comment: "最后一次修改人，外键（Users）"),
                    LastUpdateTime = table.Column<DateTime>(type: "datetime", nullable: true, comment: "最后一次修改时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProductionLineCategories", x => x.ProductionLineCategoryId);
                });

            migrationBuilder.CreateTable(
                name: "ProductionLines",
                columns: table => new
                {
                    ProductionLineId = table.Column<int>(type: "int", nullable: false, comment: "产线主键，自动编号")
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ProductionLineName = table.Column<string>(type: "varchar(30)", nullable: false, comment: "产线名称"),
                    ProductionLineCategoryId = table.Column<int>(type: "int", nullable: false, comment: "产线类型，外键（ProductionLineCategories）"),
                    ProductionTechnologyId = table.Column<int>(type: "int", nullable: false, comment: "作业工艺，外键（ProductionTechnologies）"),
                    WorkShopId = table.Column<int>(type: "int", nullable: false, comment: "所属车间，外键（WorkShops）"),
                    Status = table.Column<int>(type: "int", nullable: false, defaultValue: 0, comment: "数据状态（0正常，1删除），默认值0"),
                    CreateUserId = table.Column<int>(type: "int", nullable: false, comment: "创建人，外键（Users）"),
                    CreateTime = table.Column<DateTime>(type: "datetime", nullable: false, defaultValueSql: "GETDATE()", comment: "创建时间，默认值为当前时间"),
                    LastUpdateUserId = table.Column<int>(type: "int", nullable: true, comment: "最后一次修改人，外键（Users）"),
                    LastUpdateTime = table.Column<DateTime>(type: "datetime", nullable: true, comment: "最后一次修改时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProductionLines", x => x.ProductionLineId);
                });

            migrationBuilder.CreateTable(
                name: "ProductionPlanDetails",
                columns: table => new
                {
                    ProductionPlanDetailId = table.Column<int>(type: "int", nullable: false, comment: "产品生产计划明细主键，自动编号")
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ProductionPlanId = table.Column<int>(type: "int", nullable: false, comment: "产品生产计划，外键（ProductionPlans）"),
                    MaterialId = table.Column<int>(type: "int", nullable: false, comment: "物料信息，外键（Materials）"),
                    MaterialCount = table.Column<int>(type: "int", nullable: false, comment: "预计需要物料的数量"),
                    Status = table.Column<int>(type: "int", nullable: false, defaultValue: 0, comment: "数据状态（0正常，1删除），默认值0"),
                    CreateUserId = table.Column<int>(type: "int", nullable: false, comment: "创建人，外键（Users）"),
                    CreateTime = table.Column<DateTime>(type: "datetime", nullable: false, defaultValueSql: "GETDATE()", comment: "创建时间，默认值为当前时间"),
                    LastUpdateUserId = table.Column<int>(type: "int", nullable: true, comment: "最后一次修改人，外键（Users）"),
                    LastUpdateTime = table.Column<DateTime>(type: "datetime", nullable: true, comment: "最后一次修改时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProductionPlanDetails", x => x.ProductionPlanDetailId);
                });

            migrationBuilder.CreateTable(
                name: "ProductionPlans",
                columns: table => new
                {
                    ProductionPlanId = table.Column<int>(type: "int", nullable: false, comment: "产品生产计划主键，自动编号")
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ProductionPlanCode = table.Column<string>(type: "varchar(20)", nullable: false, comment: "任务单号，不能重复"),
                    ProductionDate = table.Column<DateTime>(type: "datetime", nullable: false, comment: "生产日期"),
                    DeliveryDate = table.Column<DateTime>(type: "datetime", nullable: false, comment: "交货日期"),
                    ProductId = table.Column<string>(type: "varchar(20)", nullable: false, comment: "产品信息"),
                    TeamId = table.Column<int>(type: "int", nullable: false, comment: "生产班组，外键（Teams）"),
                    ProductionLineId = table.Column<int>(type: "int", nullable: false, comment: "生产产线，外键（ProductionLines）"),
                    ProductionTechnologyId = table.Column<int>(type: "int", nullable: false, comment: "使用工艺"),
                    OrderCount = table.Column<int>(type: "int", nullable: false, comment: "订单数量"),
                    OrderCode = table.Column<string>(type: "varchar(20)", nullable: false, comment: "订单编号"),
                    CustomerName = table.Column<string>(type: "varchar(100)", nullable: false, comment: "客户名称"),
                    Priority = table.Column<int>(type: "int", nullable: false, defaultValue: 0, comment: "优先级（0正常，1紧急），默认值0"),
                    ProductionPlanStatus = table.Column<int>(type: "int", nullable: false, defaultValue: 0, comment: "生产计划状态（0待产，1生产中，2暂停生产，3完成），默认值0"),
                    Status = table.Column<int>(type: "int", nullable: false, defaultValue: 0, comment: "数据状态（0正常，1删除），默认值0"),
                    CreateUserId = table.Column<int>(type: "int", nullable: false, comment: "创建人，外键（Users）"),
                    CreateTime = table.Column<DateTime>(type: "datetime", nullable: false, defaultValueSql: "GETDATE()", comment: "创建时间，默认值为当前时间"),
                    LastUpdateUserId = table.Column<int>(type: "int", nullable: true, comment: "最后一次修改人，外键（Users）"),
                    LastUpdateTime = table.Column<DateTime>(type: "datetime", nullable: true, comment: "最后一次修改时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProductionPlans", x => x.ProductionPlanId);
                });

            migrationBuilder.CreateTable(
                name: "ProductionProcesses",
                columns: table => new
                {
                    ProductionProcessId = table.Column<int>(type: "int", nullable: false, comment: "工序主键，自动编号")
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ProductionProcessCode = table.Column<string>(type: "varchar(20)", nullable: false, comment: "工序编号，不能重复"),
                    ProductionProcessName = table.Column<string>(type: "varchar(30)", nullable: false, comment: "工序名称，不能重复"),
                    ProcessRequirements = table.Column<string>(type: "varchar(200)", nullable: false, comment: "工序要求"),
                    ProcessDrawings = table.Column<byte[]>(type: "image", nullable: true, comment: "工序图纸"),
                    Remark = table.Column<string>(type: "varchar(150)", nullable: true, comment: "备注"),
                    Status = table.Column<int>(type: "int", nullable: false, defaultValue: 0, comment: "数据状态（0正常，1删除），默认值0"),
                    CreateUserId = table.Column<int>(type: "int", nullable: false, comment: "创建人，外键（Users）"),
                    CreateTime = table.Column<DateTime>(type: "datetime", nullable: false, defaultValueSql: "GETDATE()", comment: "创建时间，默认值为当前时间"),
                    LastUpdateUserId = table.Column<int>(type: "int", nullable: true, comment: "最后一次修改人，外键（Users）"),
                    LastUpdateTime = table.Column<DateTime>(type: "datetime", nullable: true, comment: "最后一次修改时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProductionProcesses", x => x.ProductionProcessId);
                });

            migrationBuilder.CreateTable(
                name: "ProductionTechnologies",
                columns: table => new
                {
                    ProductionTechnologyId = table.Column<int>(type: "int", nullable: false, comment: "工艺主键，自动编号")
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ProductionTechnologyCode = table.Column<string>(type: "varchar(20)", nullable: false, comment: "工艺编号，不能重复"),
                    ProductionTechnologyName = table.Column<string>(type: "varchar(30)", nullable: false, comment: "工艺名称，不能重复"),
                    GenerationDate = table.Column<DateTime>(type: "datetime", nullable: false, comment: "生成日期"),
                    ProductId = table.Column<int>(type: "int", nullable: false, comment: "产品信息，外键（Products）"),
                    MaterialId = table.Column<int>(type: "int", nullable: false, comment: "物料信息，外键（Materials）"),
                    Status = table.Column<int>(type: "int", nullable: false, defaultValue: 0, comment: "数据状态（0正常，1删除），默认值0"),
                    CreateUserId = table.Column<int>(type: "int", nullable: false, comment: "创建人，外键（Users）"),
                    CreateTime = table.Column<DateTime>(type: "datetime", nullable: false, defaultValueSql: "GETDATE()", comment: "创建时间，默认值为当前时间"),
                    LastUpdateUserId = table.Column<int>(type: "int", nullable: true, comment: "最后一次修改人，外键（Users）"),
                    LastUpdateTime = table.Column<DateTime>(type: "datetime", nullable: true, comment: "最后一次修改时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProductionTechnologies", x => x.ProductionTechnologyId);
                });

            migrationBuilder.CreateTable(
                name: "ProductionTechnologyDetails",
                columns: table => new
                {
                    ProductionTechnologyDetailId = table.Column<int>(type: "int", nullable: false, comment: "工艺明细主键，自动编号")
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ProductionTechnologyId = table.Column<int>(type: "int", nullable: false, comment: "工艺主键，外键（ProductionTechnologies）"),
                    ProductionProcessId = table.Column<string>(type: "varchar(20)", nullable: false, comment: "工序主键，外键（ProductionProcesses）"),
                    Status = table.Column<int>(type: "int", nullable: false, defaultValue: 0, comment: "数据状态（0正常，1删除），默认值0"),
                    CreateUserId = table.Column<int>(type: "int", nullable: false, comment: "创建人，外键（Users）"),
                    CreateTime = table.Column<DateTime>(type: "datetime", nullable: false, defaultValueSql: "GETDATE()", comment: "创建时间，默认值为当前时间"),
                    LastUpdateUserId = table.Column<int>(type: "int", nullable: true, comment: "最后一次修改人，外键（Users）"),
                    LastUpdateTime = table.Column<DateTime>(type: "datetime", nullable: true, comment: "最后一次修改时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProductionTechnologyDetails", x => x.ProductionTechnologyDetailId);
                });

            migrationBuilder.CreateTable(
                name: "Products",
                columns: table => new
                {
                    ProductId = table.Column<int>(type: "int", nullable: false, comment: "产品主键，自动编号")
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ProductCode = table.Column<string>(type: "varchar(20)", nullable: false, comment: "产品编码，不能重复"),
                    ProductName = table.Column<string>(type: "varchar(80)", nullable: false, comment: "产品名称，不能重复"),
                    MaintainerId = table.Column<int>(type: "int", nullable: false, comment: "产品维护人，外键(Users)"),
                    MaintenanceTime = table.Column<int>(type: "int", nullable: false, comment: "维护时间"),
                    ProductCategoryId = table.Column<int>(type: "int", nullable: false, comment: "产品类型，外键（ProductCategories）"),
                    ProductSpecId = table.Column<int>(type: "int", nullable: false, comment: "产品规格，外键（ProductSpecs）"),
                    ProductUnitId = table.Column<int>(type: "int", nullable: false, comment: "单位，外键（Units）"),
                    ProductImage = table.Column<byte[]>(type: "image", nullable: true, comment: "产品图片"),
                    Status = table.Column<int>(type: "int", nullable: false, defaultValue: 0, comment: "数据状态（0正常，1删除）默认值0"),
                    CreateUserId = table.Column<int>(type: "int", nullable: false, comment: "创建人，外键（Users）"),
                    CreateTime = table.Column<DateTime>(type: "dateTime default getdate()", nullable: false, comment: "创建时间，默认值为当前时间"),
                    LastUpdateUserId = table.Column<int>(type: "int", nullable: true, comment: "最后一次修改人，外键（Users）"),
                    LastUpdateTime = table.Column<DateTime>(type: "dateTime", nullable: true, comment: "最后一次修改时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Products", x => x.ProductId);
                });

            migrationBuilder.CreateTable(
                name: "Stores",
                columns: table => new
                {
                    StoreId = table.Column<int>(type: "int", nullable: false, comment: "仓库主键，自动编号")
                        .Annotation("SqlServer:Identity", "1, 1"),
                    StoreCode = table.Column<string>(type: "varchar(20)", nullable: false, comment: "仓库编码，不能重复"),
                    StoreName = table.Column<string>(type: "varchar(30)", nullable: false, comment: "仓库名称，不能重复"),
                    Storekeeper = table.Column<int>(type: "int", nullable: false, comment: "仓管员，外键（Users）"),
                    StoreAddress = table.Column<string>(type: "varchar(100)", nullable: false, comment: "仓库地址"),
                    StoreCategoryId = table.Column<int>(type: "int", nullable: false, comment: "仓库类型，外键（StoreCategories）"),
                    Status = table.Column<int>(type: "int", nullable: false, defaultValue: 0, comment: "数据状态（0正常，1删除），默认值0"),
                    CreateUserId = table.Column<int>(type: "int", nullable: false, comment: "创建人，外键（Users）"),
                    CreateTime = table.Column<DateTime>(type: "datetime", nullable: false, defaultValueSql: "GETDATE()", comment: "创建时间，默认值为当前时间"),
                    LastUpdateUserId = table.Column<int>(type: "int", nullable: true, comment: "最后一次修改人，外键（Users）"),
                    LastUpdateTime = table.Column<DateTime>(type: "datetime", nullable: true, comment: "最后一次修改时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Stores", x => x.StoreId);
                });

            migrationBuilder.CreateTable(
                name: "TeamMembers",
                columns: table => new
                {
                    TeamMemberId = table.Column<int>(type: "int", nullable: false, comment: "班级成员主键，自动编号")
                        .Annotation("SqlServer:Identity", "1, 1"),
                    TeamId = table.Column<int>(type: "int", nullable: false, comment: "班组主键，外键（Teams）"),
                    MemberId = table.Column<int>(type: "int", nullable: false, comment: "班组成员名称，外键（Users）"),
                    Status = table.Column<int>(type: "int", nullable: false, defaultValue: 0, comment: "数据状态（0正常，1删除），默认值0"),
                    CreateUserId = table.Column<int>(type: "int", nullable: false, comment: "创建人，外键（Users）"),
                    CreateTime = table.Column<DateTime>(type: "datetime", nullable: false, defaultValueSql: "GETDATE()", comment: "创建时间，默认值为当前时间"),
                    LastUpdateUserId = table.Column<int>(type: "int", nullable: true, comment: "最后一次修改人，外键（Users）"),
                    LastUpdateTime = table.Column<DateTime>(type: "datetime", nullable: true, comment: "最后一次修改时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TeamMembers", x => x.TeamMemberId);
                });

            migrationBuilder.CreateTable(
                name: "Teams",
                columns: table => new
                {
                    TeamId = table.Column<int>(type: "int", nullable: false, comment: "班组主键，自动编号")
                        .Annotation("SqlServer:Identity", "1, 1"),
                    TeamName = table.Column<string>(type: "varchar(30)", nullable: false, comment: "班组名称，不能重复"),
                    TeamContact = table.Column<int>(type: "int", nullable: false, comment: "班组主要负责人，外键（Users）"),
                    Status = table.Column<int>(type: "int", nullable: false, defaultValue: 0, comment: "数据状态（0正常，1删除），默认值0"),
                    CreateUserId = table.Column<int>(type: "int", nullable: false, comment: "创建人，外键（Users）"),
                    CreateTime = table.Column<DateTime>(type: "datetime", nullable: false, defaultValueSql: "GETDATE()", comment: "创建时间，默认值为当前时间"),
                    LastUpdateUserId = table.Column<int>(type: "int", nullable: true, comment: "最后一次修改人，外键（Users）"),
                    LastUpdateTime = table.Column<DateTime>(type: "datetime", nullable: true, comment: "最后一次修改时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Teams", x => x.TeamId);
                });

            migrationBuilder.CreateTable(
                name: "WorkShopCategories",
                columns: table => new
                {
                    WorkShopCategoryId = table.Column<int>(type: "int", nullable: false, comment: "车间类型主键，自动编号")
                        .Annotation("SqlServer:Identity", "1, 1"),
                    WorkShopCategoryName = table.Column<string>(type: "varchar(30)", nullable: false, comment: "车间类型名称，不能重复"),
                    Status = table.Column<int>(type: "int", nullable: false, defaultValue: 0, comment: "数据状态（0正常，1删除），默认值0"),
                    CreateUserId = table.Column<int>(type: "int", nullable: false, comment: "创建人，外键（Users）"),
                    CreateTime = table.Column<DateTime>(type: "datetime", nullable: false, defaultValueSql: "GETDATE()", comment: "创建时间，默认值为当前时间"),
                    LastUpdateUserId = table.Column<int>(type: "int", nullable: true, comment: "最后一次修改人，外键（Users）"),
                    LastUpdateTime = table.Column<DateTime>(type: "datetime", nullable: true, comment: "最后一次修改时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WorkShopCategories", x => x.WorkShopCategoryId);
                });

            migrationBuilder.CreateTable(
                name: "WorkShops",
                columns: table => new
                {
                    WorkShopId = table.Column<int>(type: "int", nullable: false, comment: "车间主键，自动编号")
                        .Annotation("SqlServer:Identity", "1, 1"),
                    WorkShopName = table.Column<string>(type: "varchar(30)", nullable: false, comment: "车间名称，不能重复"),
                    WorkShopContactId = table.Column<int>(type: "int", nullable: false, comment: "车间负责人，外键（Users）"),
                    WorkShopCategoryId = table.Column<int>(type: "int", nullable: false, comment: "车间类型，外键（WorkShopCategories）"),
                    Status = table.Column<int>(type: "int", nullable: false, defaultValue: 0, comment: "数据状态（0正常，1删除），默认值0"),
                    CreateUserId = table.Column<int>(type: "int", nullable: false, comment: "创建人，外键（Users）"),
                    CreateTime = table.Column<DateTime>(type: "datetime", nullable: false, defaultValueSql: "GETDATE()", comment: "创建时间，默认值为当前时间"),
                    LastUpdateUserId = table.Column<int>(type: "int", nullable: true, comment: "最后一次修改人，外键（Users）"),
                    LastUpdateTime = table.Column<DateTime>(type: "datetime", nullable: true, comment: "最后一次修改时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WorkShops", x => x.WorkShopId);
                });
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "DeviceCategories");

            migrationBuilder.DropTable(
                name: "DeviceInspections");

            migrationBuilder.DropTable(
                name: "DeviceMaintenances");

            migrationBuilder.DropTable(
                name: "Devices");

            migrationBuilder.DropTable(
                name: "DeviceSpecs");

            migrationBuilder.DropTable(
                name: "MaterialReceiveDetails");

            migrationBuilder.DropTable(
                name: "MaterialReceives");

            migrationBuilder.DropTable(
                name: "ProductionLineCategories");

            migrationBuilder.DropTable(
                name: "ProductionLines");

            migrationBuilder.DropTable(
                name: "ProductionPlanDetails");

            migrationBuilder.DropTable(
                name: "ProductionPlans");

            migrationBuilder.DropTable(
                name: "ProductionProcesses");

            migrationBuilder.DropTable(
                name: "ProductionTechnologies");

            migrationBuilder.DropTable(
                name: "ProductionTechnologyDetails");

            migrationBuilder.DropTable(
                name: "Products");

            migrationBuilder.DropTable(
                name: "Stores");

            migrationBuilder.DropTable(
                name: "TeamMembers");

            migrationBuilder.DropTable(
                name: "Teams");

            migrationBuilder.DropTable(
                name: "WorkShopCategories");

            migrationBuilder.DropTable(
                name: "WorkShops");
        }
    }
}
